Completed
Branch master (d2f96a)
by Rafael S.
02:27
created

nav.js ➔ scrollToNavItem   A

Complexity

Conditions 3

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 10
rs 10
c 0
b 0
f 0
cc 3
1
function scrollToNavItem() {
2
    var path = window.location.href.split('/').pop().replace(/\.html/, '');
3
    document.querySelectorAll('nav a').forEach(function(link) {
4
      var href = link.attributes.href.value.replace(/\.html/, '');
5
      if (path === href) {
6
        link.scrollIntoView({block: 'center'});
7
        return;
8
      }
9
    })
10
  }
11
12
  scrollToNavItem();
13